﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace JamesThew.Dashboard
{
    public partial class Categories : System.Web.UI.Page
    {
        public bool isEditMode;
        public String HeaderCSS;
        public CategoryDB cdb;
        protected void Page_Load(object sender, EventArgs e)
        {
            this.cdb = new CategoryDB();
        }

        protected void GridViewCategory_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridViewCategory.Columns[4].Visible = true;
            //GridViewCategory.Columns[5].Visible = false;
        }

        protected void btnAddCategory_Click(object sender, EventArgs e)
        {
            String CategoryName = this.txtCatName.Text;
            int CategoryParent = JamesThew.Includes.Core.ParseInt(this.ddParent.SelectedValue);
            String CategoryDescription = this.txtDescription.Text;

            Category cat = new Category(CategoryName, CategoryDescription, CategoryParent, 0);
            Boolean res = this.cdb.Add(cat);

            if (res == false)
            {
                Response.Write("Unable to create category, please check your information");
            }
            else 
            {
                Response.Redirect("Categories.aspx");
            }
        }
    }
}